package  com.fairytask.ui.petsUnit
{
	import com.fairytask.data.ObjectData;
	import com.fairytask.data.SceneObject;
	import com.fairytask.data.ViewObject;
	import com.fairytask.define.ViewDefine;
	import com.fairytask.engine.GameStage;
	import com.fairytask.engine.components.ToolTips;
	import com.fairytask.engine.components.button.Button;
	import com.fairytask.engine.components.clip.Clip;
	import com.fairytask.engine.components.comboBox.ComboBox;
	import com.fairytask.engine.components.text.Input;
	import com.fairytask.engine.components.text.Label;
	import com.fairytask.engine.define.ResConfig;
	import com.fairytask.managers.TipsManage;
	import com.fairytask.objects.Player;
	import com.fairytask.resource.StaticIni;
	import com.fairytask.tools.TipsTools;
	import com.fairytask.ui.InfoUI;
	import com.fairytask.ui.base.UnitUI;
	import com.fairytask.ui.item.BagItemBak;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.events.TimerEvent;
	import flash.geom.Point;
	
	/**
	 * 装备栏属性UI 
	 * @author xujh
	 * 
	 */
	public class PetEquipUI extends UnitUI
	{
		private static var _self		:PetEquipUI;
		//=========显示面板====================================================
		public var modelBg		:MovieClip;//模型背景
		
		//装备显示
		public var eq_head_bg  :MovieClip;		//头
		public var eq_line_bg  :MovieClip;		//链
		public var eq_arm_bg   :MovieClip;		//武
		public var eq_chest_bg :MovieClip;		//衣
		public var eq_foot_bg  :MovieClip;		//鞋
		public var eq_ring_bg  :MovieClip;		//戒
		
		//属性数值
//		public var equip_value:Label;	//装备评分
//		public var equip_value_input:Input;//装备评分
		public var propSp		:Sprite = new Sprite();
		public var HPLabel		:Label;	//HP
		public var HPInput		:Input;
		public var MPLabel		:Label;	//MP
		public var MPInput 	:Input;
		public var strLabel	:Label;	//力量
		public var strInput 	:Input;
		public var phyLabel	:Label;	//物攻
		public var phyInput 	:Input;
		public var ingLabel	:Label;	//智力
		public var ingInput 	:Input;
		public var magLabel	:Label;	//法攻
		public var magInput 	:Input;
		public var spiLabel	:Label;	//耐力
		public var spiInput 	:Input;
		public var phyDefLabel	:Label;	//物防
		public var phyDefInput :Input;
		public var dexLabel	:Label;	//敏捷
		public var dexInput 	:Input;
		public var magDefLabel	:Label;	//法防
		public var magDefInput :Input;
		public var expLabel	:Label;	//经验
		public var expInput	:Input;
		
		//=============人物部分显示=====================
		public var playerSpace	:Sprite = new Sprite();
		public var nameLab		:Label;	//姓名
		public var levelLab	:Label;	//等级
		public var titleLab	:Label;	//称号
		public var titleIpt	:ComboBox;
		public var postLab		:Label;	//职位
		public var postIpt		:Input;
		
		//=============宠物部分显示=====================
		public var petSpace	:Sprite = new Sprite();
		public var petNameLab	:Label;
		public var petLevelLab	:Label;
		public var petUpgrade	:Button;	//升级
		public var petSprLab	:Label;		//所需灵
		//宠物评分星级容器
		private var starSpace	:Sprite = new Sprite();
		
		public var takeoffBtn	:Button;	//卸下按钮
		//装备容器
		private var personEquip :Sprite;
		//人物模型容器
		private var modelSpace	:Sprite	= new Sprite();
		//装备模型容器
		private var weaponSpace:Sprite	= new Sprite();
		
		private var _modelMc	:MovieClip;	//人物模型
		private var _weaponMc	:MovieClip;	//装备模型
		private var _info		:InfoUI		=	InfoUI.getInstance();
		
		//===================记录的数据========================
		private var _isPlayer	:Boolean;	//是人物
		private var _lvExp		:String;
		private var _nowExp	:String;
		private var _nowLevel	:String;
		private var _equip			:Array=[];		//装备
		private var _data			:ObjectData;	//显示对象
		private var _bindArr		:Array	=[];	//绑定数据的数组，用于解绑
		private var _bindView		:Array	=[];	//绑定的视图
		private var _initBind		:Boolean = false;	//第一次打开时做的绑定
		private var _doubleClick	:Boolean;
		private var _curPos	:int;		//当前点击对象位置
		private var _btnX		:int;
		private var _btnY		:int;
		private var _curObj	:Point;		//当前对象
		private var _curView	:int;		//当前宠物视图
		
		private var _tmpPos	:int;
		private var _nameStr	:String;
		private var _color		:int;
		
		public static function getInstance():PetEquipUI
		{
			if (_self == null)
			{
				_self=new PetEquipUI;
			}
			return _self;
		}
		
		public function PetEquipUI()
		{
			super();
		}
		
		override public function initGUI():void
		{
			//把装备放入装备数组，编号从1开始
			_equip=new Array("",eq_head_bg,
				eq_arm_bg,
				eq_foot_bg,
				eq_line_bg,
				eq_chest_bg,
				eq_ring_bg);
			
			personEquip = new Sprite();
			personEquip.x = 60;
			personEquip.y = 105;
			windowBG.addChild(personEquip);
			personEquip.addChild(modelSpace);
			personEquip.addChild(weaponSpace);
			personEquip.mouseEnabled = false;
			personEquip.mouseChildren= false;
			
			//初始化宠物人物不同信息显示容器
			windowBG.addChild(propSp);
			windowBG.addChild(playerSpace);
			windowBG.addChild(petSpace);
			starSpace.x = 20;
			starSpace.y = 200;
			petSpace.addChild(starSpace);
			petSpace.visible = false;
			
			//添加装备事件
			initEvent();
			
			//选项初始化
			takeoffBtn.visible = false;
			takeoffBtn.addEventListener(MouseEvent.CLICK,onTakeOff);
		}
		
		/**
		 * 初始化事件 
		 */		
		private function initEvent():void
		{
			//人物属性面板事件
			//=======================================================================================
			//装备面板图标注册监听：单击、双击、拖动……
			for (var i:int=1;i<_equip.length;i++)
			{
				_equip[i].pos = i;
				_equip[i].doubleClickEnabled=true;
				_equip[i].mouseChildren=false;
				_equip[i].addEventListener(MouseEvent.DOUBLE_CLICK,onDouble);
				_equip[i].addEventListener(MouseEvent.CLICK,onClick);
				_equip[i].addEventListener(MouseEvent.MOUSE_OVER,onOver);
				_equip[i].addEventListener(MouseEvent.MOUSE_OUT,onOut);
				var equip:BagItemBak = new BagItemBak();
				equip.x	=	-2;
				equip.y	=	-2;
				_equip[i].addChild(equip);
				_equip[i].data = null;
				_equip[i].equip = equip;
				GameStage.stage.addEventListener(MouseEvent.MOUSE_UP,hideBtn);
			}
			
			//升级宠物
			petUpgrade.addEventListener(MouseEvent.CLICK,onPetUp);
		}
		
		/**
		 * 添加数据绑定 
		 * 
		 */
		private function addBindData():void
		{
			_bindArr.push([_data,"Name",bindManager.BindProp(_data, "Name",this,"rName")]);	//名字
			
			_bindArr.push([_data,"Str",bindManager.BindProp(_data, "Str",this,"rStr")]);		//力量
			_bindArr.push([_data,"StrAdd",bindManager.BindProp(_data, "StrAdd",this,"rStr")]);//力量修正
			_bindArr.push([_data,"Ing",bindManager.BindProp(_data, "Ing",this,"rIng")]);		//智力
			_bindArr.push([_data,"IngAdd",bindManager.BindProp(_data, "IngAdd",this,"rIng")]);//智力修正
			_bindArr.push([_data,"Dex",bindManager.BindProp(_data, "Dex",this,"rDex")]);		//敏捷
			_bindArr.push([_data,"DexAdd",bindManager.BindProp(_data, "DexAdd",this,"rDex")]);//敏捷修正
			_bindArr.push([_data,"Spi",bindManager.BindProp(_data, "Spi",this,"rSpi")]);		//敏捷
			_bindArr.push([_data,"SpiAdd",bindManager.BindProp(_data, "SpiAdd",this,"rSpi")]);//敏捷修正
			
			_bindArr.push([_data,"PhyDamage",bindManager.BindProp(_data, "PhyDamage",this,"rPhyDamage")]);//物理攻击
			_bindArr.push([_data,"PhyDamageAdd",bindManager.BindProp(_data, "PhyDamageAdd",this,"rPhyDamage")]);		//物理攻击
			_bindArr.push([_data,"PhyDamageMul",bindManager.BindProp(_data, "PhyDamageMul",this,"rPhyDamage")]);//物理攻击
			
			_bindArr.push([_data,"MagDamage",bindManager.BindProp(_data, "MagDamage",this,"rMagDamage")]);//法力攻击
			_bindArr.push([_data,"MagDamageAdd",bindManager.BindProp(_data, "MagDamageAdd",this,"rMagDamage")]);		//法力攻击
			_bindArr.push([_data,"MagDamageMul",bindManager.BindProp(_data, "MagDamageMul",this,"rMagDamage")]);//法力攻击
			
			_bindArr.push([_data,"PhyDef",bindManager.BindProp(_data, "PhyDef",this,"rPhyDef")]);		//物妨
			_bindArr.push([_data,"PhyDefAdd",bindManager.BindProp(_data, "PhyDefAdd",this,"rPhyDef")]);//物妨
			_bindArr.push([_data,"PhyDefMul",bindManager.BindProp(_data, "PhyDefMul",this,"rPhyDef")]);//物妨
			
			_bindArr.push([_data,"MagDef",bindManager.BindProp(_data, "MagDef",this,"rMagDef")]);		//法防
			_bindArr.push([_data,"MagDefAdd",bindManager.BindProp(_data, "MagDefAdd",this,"rMagDef")]);//法防
			_bindArr.push([_data,"MagDefMul",bindManager.BindProp(_data, "MagDefMul",this,"rMagDef")]);//法防
			
			_bindArr.push([_data,"Level",bindManager.BindProp(_data, "Level",this,"rlevel")]);			//等级
			_bindArr.push([_data,"PlayerExp",bindManager.BindProp(_data, "PlayerExp",this,"rExp")]);	//经验
			
			_bindArr.push([_data,"HP",bindManager.BindProp(_data, "HP",this,"rHp")]);		//气血
			_bindArr.push([_data,"MaxHP",bindManager.BindProp(_data, "MaxHP",this,"rHp")]);//气血
			_bindArr.push([_data,"MaxHPAdd",bindManager.BindProp(_data, "MaxHPAdd",this,"rHp")]);//最大气血
			
			_bindArr.push([_data,"ST",bindManager.BindProp(_data, "ST",this,"rST")]);		//体力
			
			_bindArr.push([_data,"Model",bindManager.BindProp(_data, "Model",this,"roleModel")]);		//人物模型
			_bindArr.push([_data,"WeaponModel",bindManager.BindProp(_data, "WeaponModel",this,"weaponModel")]);//武器模型
		}
		
		/**
		 * 绑定视图 
		 * 
		 */
		private function setBindView():void
		{
			//是人物绑定装备，否则绑定当前装备列表
			if(_isPlayer)
			{
				//人物要绑称号
				_bindArr.push([_data,"Title",bindManager.BindProp(_data, "Title",this,"rTitle")]);
			}
			else
			{
				_bindArr.push([_data,"Color",bindManager.BindProp(_data, "Color",this,"rColor")]);	//获取颜色
				_bindArr.push([_data,"Spirit",bindManager.BindProp(_data, "Spirit",this,"rSpirit")]);			//需要的灵
			}
			_bindView = [_curView,bindManager.BindView(model.scene, _curView, onAddEquip, onDelEquip)];
			setShowSp();
		}
		
		private function setShowSp():void
		{
			playerSpace.visible = _isPlayer;
			petSpace.visible = !_isPlayer;
			//是玩家的时候为止调整
			if(_isPlayer)
			{
				propSp.y = 0;
			}
			else
			{
				propSp.y = 20;
			}
		}
		
		/**
		 * 解绑数据 
		 * 
		 */
		private function removeBindData():void
		{
			//全部解绑
			for each(var itemBind:Array in _bindArr)
			{
				bindManager.UnbindProp(itemBind.shift(),itemBind.shift(),itemBind.shift());
			}
			_bindArr = [];
			bindManager.UnbindView(_bindView.shift(),_bindView.shift());
		}
		
		//===========================装备视图添加删除处理=====================================
		/**
		 * 先删除原有装备 
		 * @param key
		 * @param val
		 * @param data
		 * //头部(头)	equip_left.head		= 1
		 //武器(武)	equip_left.arm		= 2,
		 //鞋子(脚)	equip_left.foot		= 3,
		 //项链(项)	equip_right.line	= 4,
		 //铠甲(甲)	equip_left.chest	= 5,
		 //戒指(指)	equip_right.ring	= 6,
		 * 
		 */		
		private function onDelEquip(key:String, val:ViewObject, data:Object):void
		{
			var pos	:int	=	val.GetPropertiesEx("Pos");	
			clearEquip(pos);
		}
		
		/**
		 * 再添加新装备 
		 * @param key
		 * @param val
		 * @param data
		 * 
		 */		
		private function onAddEquip(key:String, val:ViewObject, data:Object):void
		{
			if(val.GetPropertiesEx("ConfigID")=="")
			{
				return;
			}
			var pos:int	=	val.GetPropertiesEx("Pos");
			if(_equip[pos].data == null)
			{
				_equip[pos].equip.source = ResConfig.iconPath + StaticIni.getIniVar(val.GetPropertiesEx("ConfigID"),"Icon") + ".png";
				_equip[pos].data = val;
			}
		}
		
		//============================鼠标事件=========================================
		/**
		 * 单击弹出小菜单 
		 * @param evt
		 * 
		 */		
		private function onClick(evt:MouseEvent):void
		{
			
		}
		
		/**
		 * 选中位置,加选中效果
		 * 
		 */
		private function selectPos(pos:int):void
		{
			
		}
		
		/**
		 * 双击
		 * @param evt
		 * 
		 */		
		private function onDouble(evt:MouseEvent):void
		{
			_doubleClick = true;
		}
		
		/**
		 * 单击双击判断
		 * @param evt
		 * 
		 */
		private function checkClick(evt:TimerEvent):void 
		{
			if(_doubleClick)
			{
				sendMessage();
			}
			else
			{
				if(!takeoffBtn.visible)
				{
					takeoffBtn.visible = true;
					takeoffBtn.x = _btnX;
					takeoffBtn.y = _btnY;
				}
				else
				{
					takeoffBtn.visible = false;
				}
			}
		}
		
		/**
		 * 点击卸下选项
		 * @param evt
		 * 
		 */		
		private function onTakeOff(evt:MouseEvent):void
		{
			sendMessage();
		}
		
		private function sendMessage():void
		{
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_USEITEM,3,_curView,_curPos,_curObj);
		}
		
		/**
		 * 点击其他地方隐藏菜单
		 * @param evt
		 * 
		 */		
		private function hideBtn(evt:MouseEvent):void
		{
			takeoffBtn.visible = false;
		}
		
		/**
		 * 显示装备tips 
		 * @param evt
		 * 
		 */
		private function onOver(evt:MouseEvent):void
		{
			if(_equip[evt.currentTarget.pos].data!=null)
			{
				var configID:int=_equip[evt.currentTarget.pos].data.GetPropertiesEx("ConfigID");
				TipsManage.ShowAllItemsTips(int(StaticIni.getIniVar(String(configID),"ItemType")),configID,_equip[evt.currentTarget.pos].data);
			}
		}
		
		/**
		 * 隐藏tips 
		 * @param evt
		 * 
		 */
		private function onOut(evt:MouseEvent):void
		{
			ToolTips.hide();
		}
		
		/**
		 * 宠物升级 
		 * @param evt
		 * 
		 */
		private function onPetUp(evt:MouseEvent):void
		{
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_PETEXP,_curObj);
		}
		//============================鼠标事件结束=========================================
		
		
		//==========================绑定数据处理=======================================
		//设置颜色
		public function set rColor(val:int):void
		{
			_color = val;
			petNameLab.htmlStrByBorder = TipsTools.link_color(_nameStr,_color,14);
			petLevelLab.x = petNameLab.x + petNameLab.width + 5;
			addStar(val);
		}
		
		/**
		 * 添加星星 
		 * @param val
		 * 
		 */
		private function addStar(val:int):void
		{
			for(var i:int=0;i<val;i++)
			{
				if(i<starSpace.numChildren)
				{
					starSpace.getChildAt(i).visible = true;
				}
				else
				{
					var star	:Clip = new Clip();
					star.source	=	ResConfig.pngResPath + "tips_star2.png";
					star.width = star.height = 15;
					star.x = i*17;
					starSpace.addChild(star);
				}
			}
		}
		
		//设置名字
		public function set rName(val:String):void
		{
			if(_isPlayer)
			{
				nameLab.htmlStrByBorder = val;
				nameLab.x = 140 - nameLab.width/2;
			}
			else
			{
				petNameLab.htmlStrByBorder = TipsTools.link_color(val,_color,14);
				_nameStr = val;
				petLevelLab.x = petNameLab.x + petNameLab.width + 5;
			}
		}
		//力量
		public function set rStr(val:String):void
		{
			var propVal	:int = _data.GetPropertiesEx("Str");
			var propAdd	:int = _data.GetPropertiesEx("StrAdd");//附加值
			setVal(strInput,propVal,propAdd);
		}
		
		//智力
		public function set rIng(val:String):void
		{
			var propVal	:int = _data.GetPropertiesEx("Ing");
			var propAdd	:int = _data.GetPropertiesEx("IngAdd");//附加值
			setVal(ingInput,propVal,propAdd);
		}
		
		//耐力
		public function set rSpi(val:String):void
		{
			var propVal	:int = _data.GetPropertiesEx("Spi");
			var propAdd	:int = _data.GetPropertiesEx("SpiAdd");//附加值
			setVal(spiInput,propVal,propAdd);
		}
		
		//敏捷
		public function set rDex(val:String):void
		{
			var propVal	:int = _data.GetPropertiesEx("Dex");
			var propAdd	:int = _data.GetPropertiesEx("DexAdd");//附加值
			setVal(dexInput,propVal,propAdd);
		}
		
		/**
		 *物理攻击 
		 * @param val
		 * 
		 */		
		public function set rPhyDamage(val:String):void
		{
			//phyInput.htmlStr = ProfileTools.retrieveDamage(_data,ProfileTools.PHYSICAL);
		}
		
		/**
		 *法术攻击 
		 * @param val
		 * 
		 */		
		public function set rMagDamage(val:String):void
		{
			//magInput.htmlStr = ProfileTools.retrieveDamage(_data,ProfileTools.MAGICAL);
		}
		
		/**
		 * 气血HP
		 * @param val
		 * 
		 */
		public function set rHp(val:String):void
		{
			HPInput.htmlStr=_data.GetPropertiesEx("HP")+"/"+(int(_data.GetPropertiesEx("MaxHP"))+int(_data.GetPropertiesEx("MaxHPAdd")));
		}
		
		/**
		 * 法力 MP
		 * @param val
		 * 
		 */		
		public function set rST(val:String):void
		{
			MPInput.htmlStr=_data.GetPropertiesEx("ST");
		}
		
		/**
		 * 当前经验 
		 * @param val
		 * 
		 */		
		public function set rExp(val:String):void
		{
			//当前经验
			_nowExp = val;
			expInput.htmlStr = val + "/" + _lvExp;
		}
		
		/**
		 * 设置等级 
		 * @param val
		 * 
		 */
		public function set rlevel(val:String):void
		{
			if(_isPlayer)
			{
				levelLab.htmlStrByBorder = StaticIni.getSwfLangStr("1000000062") + val;
				levelLab.x = 140 - levelLab.width/2;
			}
			else
			{
				petLevelLab.htmlStrByBorder = StaticIni.getSwfLangStr("1000000062") + val;
			}
			_nowLevel	=	val;
			_lvExp = StaticIni.getIniVar("lv_" + _nowLevel,"EXP");
			expInput.htmlStr = val + "/" + _lvExp;
		}
		
		/**
		 * 法防 
		 * @param val
		 * 
		 */
		public function set rMagDef(val:String):void
		{
			magDefInput.htmlStr=String(int((_data.GetPropertiesEx("MagDef")+_data.GetPropertiesEx("MagDefAdd"))*(1+_data.GetProperties("MagDefMul")/100) + 0.5));
		}
		
		/**
		 * 物防 
		 * @param val
		 * 
		 */
		public function set rPhyDef(val:String):void	
		{
			phyDefInput.htmlStr=String(int((_data.GetPropertiesEx("PhyDefAdd") + _data.GetPropertiesEx("PhyDef"))*(1 + _data.GetProperties("PhyDefMul")/100) + 0.5));
		}
		
		/**
		 * 称号 
		 * @param val
		 * 
		 */
		public function set rTitle(val:String):void
		{
			titleIpt.dataList = [val];
			titleIpt.setSelected(0);
		}
		
		public function set rSpirit(val:String):void
		{
			petSprLab.htmlStrByBorder = StaticIni.getSwfLangStrVar("1000000276",[val]);
		}
		
		/**
		 * 设置人物模型 
		 * @param val
		 * 
		 */
		public function set roleModel(val:String):void
		{
		}
		
		/**
		 * 设置装备模型 
		 * @param val
		 * 
		 */
		public function set weaponModel(val:int):void
		{
			if(val!=0)
			{
				
			}
			else
			{
				while(weaponSpace.numChildren>0)
				{
					weaponSpace.removeChildAt(0);
				}
			}
		}
		
		/**
		 * 添加Input数据 
		 * @param ipt 添加的input位置
		 * @param val 前面的数值
		 * @param valAdd 附加的数值
		 * 
		 */
		private function setVal(ipt:Input,val:int,valAdd:int):void
		{
			if(valAdd > 0)
			{
				ipt.showHtml = val.toString() + "+" + setColor(valAdd.toString());
			}
			else if(valAdd < 0)
			{
				ipt.showHtml = val.toString() + "-" + setColor(Math.abs(valAdd).toString(),"ff0000");
			}
			else
			{
				ipt.showHtml = val.toString();
			}
		}
		
		/**
		 * 设置文本颜色 
		 * @param str
		 * @param color
		 * @return 
		 * 
		 */
		private function setColor(str:String,color:String="00ff00"):String
		{
			return "<font color='#" + color +"'>" + str + "</font>";
		}
		
		/**
		 * 加载人物模型 
		 * @param val
		 * @param pList
		 * 
		 */
		private function onLoadModel(val:DisplayObject,pList:Array):void
		{
			_modelMc	=	val as MovieClip;
			if(_modelMc)
			{
				while(modelSpace.numChildren>0)
				{
					modelSpace.removeChildAt(0);
				}
				_modelMc.x	=	69;
				_modelMc.y	=	36;
				_modelMc.gotoAndPlay(0);
				modelSpace.addChild(_modelMc);
			}
		}
		
		/**
		 * 加载装备模型 
		 * @param val
		 * @param pList
		 * 
		 */
		private function onWeaponLoad(val:DisplayObject,pList:Array):void
		{
			if(val)
			{
				while(weaponSpace.numChildren>0)
				{
					weaponSpace.removeChildAt(0);
				}
				_weaponMc = val as MovieClip;
				weaponSpace.addChild(_weaponMc);
				_weaponMc.x = 69;
				_weaponMc.y = 36;
				_weaponMc.gotoAndPlay(0);
				_weaponMc.mouseEnabled = false;
				_weaponMc.mouseChildren= false;
			}
		}
		//==========================绑定数据处理完毕=======================================
		
		/**
		 * 设置属性数据 
		 * 
		 */
		public function set data(val:*):void
		{
			//数据相同返回不做操作
			if(_data == val)
			{
				return;
			}
			//先清除数据,第一次不清除
			if(_initBind)
			{
				clearAll();
			}
			_data = val;
			//设置当前数据是否是人物
		}
		
		/**
		 * 和原先的状态相同就不需要解绑重新绑定
		 * 
		 */
		private function isNeedFresh(val:Boolean):void
		{
			if(_initBind)
			{
				removeBindData();
			}
			else
			{
				_initBind = true;
			}
			//是否重新绑定视图
			/*if(_isPlayer != val)
			{
				_isPlayer = val;
				setBindView();
			}*/
			_isPlayer = val;
			//重新对数据进行绑定
			addBindData();
			setBindView();
		}
		
		//==========================清除方法=======================================
		/**
		 * 清除所有内容，为加载新的内容做准备 
		 * 
		 */
		public function clearAll():void
		{
			//清除人物模型
			while(modelSpace.numChildren>0)
			{
				modelSpace.removeChildAt(0);
			}
			//清除装备模型
			while(weaponSpace.numChildren>0)
			{
				weaponSpace.removeChildAt(0);
			}
			//清除装备显示
			for(var i:int=1;i<_equip.length;i++)
			{
				clearEquip(i);
			}
			//隐藏宠物星
			for(i=0;i<starSpace.numChildren;i++)
			{
				starSpace.getChildAt(i).visible = false;
			}
			//清除内容
			HPInput.htmlStr = "";
			MPInput.htmlStr = "";
			strInput.htmlStr = "";
			phyInput.htmlStr = "";
			ingInput.htmlStr = "";
			magInput.htmlStr = "";
			spiInput.htmlStr = "";
			phyDefInput.htmlStr = "";
			dexInput.htmlStr = "";
			magDefInput.htmlStr = "";
			expInput.htmlStr = "";
			nameLab.htmlStrByBorder = "";
			levelLab.htmlStrByBorder = "";
			petNameLab.htmlStrByBorder = "";
			petLevelLab.htmlStrByBorder = "";
			_data = null;
		}
		
		/**
		 * 清除对应位置装备
		 * @param pos
		 * 
		 */
		private function clearEquip(pos:int):void
		{
			if(_equip[pos].data!=null)
			{
//				(_equip[pos]as MovieClip).removeChild(_equip[pos].equip);
//				(_equip[pos]as MovieClip).removeChild(_equip[pos].frame);
				_equip[pos].equip.clearPhoto();
				_equip[pos].data=null;
//				_equip[pos].clip=null;
//				_equip[pos].frame=null;
//				_equip[pos].frameColor=null;
			}
		}
		
		/**
		 * 重置，默认打开人装备 
		 * 
		 */
		override public function reset():void
		{
			//this.data = Player.instance.data;
		}
	}
}